package com.sprouting.personal.model.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.sprouting.personal.annotations.CheckLength;
import com.sprouting.personal.annotations.CheckNotNull;
import com.sprouting.personal.model.common.BaseModel;
import com.sprouting.personal.model.common.jsr.AddGroup;
import com.sprouting.personal.model.common.jsr.UpdGroup;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 账单
 *
 * @author ：LX（长沙麓谷）
 * @date 创建时间： 2022/12/24 14:55
 */
@Data
@TableName("ps_bill")
public class Bill extends BaseModel {

    /**
     * 主键
     */
    @TableId
    @CheckNotNull(message = "非法ID", groups = UpdGroup.class)
    @Null(message = "无效ID", groups = AddGroup.class)
    private String id;
    /**
     * 隶属用户
     * @see User#getId()
     */
    private String userId;
    /**
     * 款项发生时间，年月日
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern="yyyy-MM-dd", timezone = "GMT+8")
    private Date triggerTime;
    /**
     * 价格-金额
     */
    private BigDecimal price;
    /**
     * 账单类型
     * @see Dict#getId()
     */
    @CheckNotNull(message = "请选择账单类型")
    private String typeId;
    /**
     * 用途说明-款项名称
     */
    @CheckLength(min = 1, max = 200, message = "用途说明超过长度限制")
    @CheckNotNull(message = "请输入用途说明")
    private String purpose;
    /**
     * 支出or收入
     * @see com.sprouting.personal.interfaces.common.Constant.RevenueExpense
     */
    @NotNull(message = "请选择是支出还是收入")
    private Integer incomeOrExpenditure;
    /**
     * 支出地点
     */
    private String place;
    /**
     * 组ID
     * 默认值，{@link com.sprouting.personal.interfaces.common.Constant.DefaultValue#STRING}
     * @see BillingGroup#getId()
     */
    private String groupId;
    /**
     * 是否入账记录-比如人情往来
     * @see com.sprouting.personal.interfaces.common.Constant.YesOrNo#YES 入账
     * @see com.sprouting.personal.interfaces.common.Constant.YesOrNo#NO 不入账
     */
    private Integer entry;
    /**
     * 核心关键账单，超过预期
     * @see com.sprouting.personal.interfaces.common.Constant.YesOrNo#YES 核心账单
     */
    private Integer core;
    /**
     * 支出方式;现金、线上
     * @see com.sprouting.personal.interfaces.common.Constant.ExpenditureType
     */
    private Integer modeOfExpenditure;
}
